APPNAME = server
APPPATH = `pwd`/../bin/${APPNAME}
CC = gcc
OBJ = `pwd`/../obj/
CFLAGS += -I `pwd`/../inc/
LIBPATH = `pwd`/../lib/
LDFLAGS += -L ${LIBPATH} -lsqlite3 -ldl  -lpthread
OBJDIR = `pwd`/../


all:create_file
	${CC} `pwd`/*.c -o ${APPPATH}   ${CFLAGS}  ${LDFLAGS}

create_file:
	$(shell if [ ! -d $(OBJDIR)bin ]; then mkdir -p $(OBJDIR)bin; fi)
	$(shell if [ ! -d $(OBJDIR)database ]; then mkdir -p $(OBJDIR)database; fi)
	$(shell if [ ! -d $(OBJDIR)logger ]; then mkdir -p $(OBJDIR)logger; fi)

clean:
	rm -rf ${OBJ}*.o
	
distclean:
	rm -rf ${OBJDIR}bin
	rm -rf ${OBJDIR}logger
	rm -rf ${OBJDIR}database
run:
	export  LD_LIBRARY_PATH={LD_LIBRARY_PATH}:${LIBPATH}
	#./${APPNAME}
